package neu.soft.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 *
 * @author 李博
 * @param <T> 泛型数据类型
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultBean <T>{
    private Integer code = 200;//成功代码
    private String msg = "success";//默认成功消息
    private T data;//封装数据

    public static <T> ResultBean<T> success(String msg, T data){
        return new ResultBean(200,msg,data);
    }

    public static <T> ResultBean<T> success(T data){
        return new ResultBean(200,"success",data);
    }

    public static <T> ResultBean success(String msg){
        return new ResultBean(200,msg,null);
    }

    public static <T> ResultBean success(){
        return new ResultBean(200,"success",null);
    }

    public static <T> ResultBean error(){
        return new ResultBean(500,"服务器内部异常",null);
    }

    public static <T> ResultBean<T> error(String msg ,T data){
        return new ResultBean(500,msg,data);
    }

    public static <T> ResultBean error(Integer code,String msg){
        return new ResultBean(code,msg,null);
    }


}
